<!--Copyright (C) Kherty.  All rights reserved.-->
<ResourceDictionary
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    x:Class="OpenLS.UI.ComboBoxResources"
    xmlns:oui="clr-namespace:OpenLS.UI"
    xmlns:Internals="clr-namespace:OpenLS.UI.Internals"
    >
    <ResourceDictionary.MergedDictionaries>
        <Internals:ResizeThumbResources/>
    </ResourceDictionary.MergedDictionaries>
 <!-- <ResourceDictionary.MergedDictionaries>
  </ResourceDictionary.MergedDictionaries> -->
  <ControlTemplate TargetType="{x:Type ToggleButton}" x:Key="toggleBInCB">
    <Grid Background="{TemplateBinding Background}" x:Name="Grid" SnapsToDevicePixels="True">
      <Grid.ColumnDefinitions>
        <ColumnDefinition Width="*"/>
        <ColumnDefinition Width="Auto" SharedSizeGroup="ComboBoxButton"/>
      </Grid.ColumnDefinitions>

      <Border BorderThickness="1" BorderBrush="Transparent" Background="Transparent" x:Name="arrowDown" Grid.Column="1" Width="{DynamicResource {x:Static SystemParameters.VerticalScrollBarWidthKey}}">
        <Path Data="M0,0 L6,0 L3,2 Z" Fill ="#FF567DB1" HorizontalAlignment="Center" VerticalAlignment="Center"/>
      </Border>
    </Grid>
    <ControlTemplate.Triggers>
      <Trigger Property ="IsMouseOver" Value="True">
                          <Setter Property="Background" Value="{DynamicResource {x:Static oui:OfficeBrushes.ComboBoxHoverBackgroundKey}}" TargetName="arrowDown"/>
                          <Setter Property="BorderBrush" Value="{DynamicResource {x:Static oui:OfficeBrushes.ComboBoxHoverBorderBrushKey}}" TargetName="arrowDown"/>
                        </Trigger>
       <Trigger Property ="IsMouseOver" Value="True" SourceName="arrowDown">
                          <Setter Property="Background" Value="{DynamicResource {x:Static oui:OfficeBrushes.ComboBoxArrowHoverBackgroundKey}}" TargetName="arrowDown"/>
                          <Setter Property="BorderBrush" Value="{DynamicResource {x:Static oui:OfficeBrushes.ComboBoxArrowHoverBorderBrushKey}}" TargetName="arrowDown"/>
                        </Trigger>
                        <Trigger Property ="IsPressed" Value="True">
                          <Setter Property="Background" Value="{DynamicResource {x:Static oui:OfficeBrushes.ComboBoxPressedBackgroundKey}}" TargetName="arrowDown"/>
                          <Setter Property="BorderBrush" Value="{DynamicResource {x:Static oui:OfficeBrushes.ComboBoxPressedBorderBrushKey}}" TargetName="arrowDown"/>
                        </Trigger>
                        <Trigger Property ="IsChecked" Value="True">
                          <Setter Property="Background" Value="{DynamicResource {x:Static oui:OfficeBrushes.ComboBoxPressedBackgroundKey}}" TargetName="arrowDown"/>
                          <Setter Property="BorderBrush" Value="{DynamicResource {x:Static oui:OfficeBrushes.ComboBoxPressedBorderBrushKey}}" TargetName="arrowDown"/>
                        </Trigger>
    </ControlTemplate.Triggers>
  </ControlTemplate>
  <ControlTemplate x:Key="ComboBoxControlTemplate1" TargetType="{x:Type ComboBox}">
    <Grid x:Name="Grid" SnapsToDevicePixels="True">
      <Grid Grid.IsSharedSizeScope="True" x:Name="Grid1">
        <Grid.ColumnDefinitions>
          <ColumnDefinition Width="1"/>
          <ColumnDefinition Width="*"/>
          <ColumnDefinition Width="Auto" SharedSizeGroup="ComboBoxButton"/>
        </Grid.ColumnDefinitions>
        
          <Border Background="{TemplateBinding Background}" Grid.ColumnSpan="3" x:Name="Bd"
                  BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Padding="0">
              <ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" Margin="{TemplateBinding Padding}" Grid.Column="1" x:Name="ContentPresenter" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" Content="{TemplateBinding SelectionBoxItem}" ContentTemplate="{TemplateBinding SelectionBoxItemTemplate}"/>
          </Border>
       
          <ToggleButton Grid.ColumnSpan="3" x:Name="ToggleButton" IsChecked="{Binding IsDropDownOpen, Mode=TwoWay, RelativeSource={RelativeSource Mode=TemplatedParent, AncestorType={x:Null}}}">
            <ToggleButton.Style>
              <Style TargetType="{x:Type ToggleButton}">
                <Setter Property="MinWidth" Value="0"/>
                <Setter Property="MinHeight" Value="0"/>
                <Setter Property="Width" Value="Auto"/>
                <Setter Property="Height" Value="Auto"/>
                <Setter Property="Background" Value="#00FFFFFF"/>
                <Setter Property="Focusable" Value="False"/>
                <Setter Property="ClickMode" Value="Press"/>
                <Setter Property="Template" Value="{StaticResource toggleBInCB}">
                </Setter>
              </Style>
            </ToggleButton.Style>
          </ToggleButton>
        </Grid>
            <Popup Height="500"
                IsOpen="{Binding IsDropDownOpen, RelativeSource={RelativeSource Mode=TemplatedParent, AncestorType={x:Null}}}"
        Focusable="False" Placement="Bottom" Name="PART_Popup"
        PopupAnimation="{DynamicResource {x:Static SystemParameters.ComboBoxPopupAnimationKey}}" AllowsTransparency="True"
        MaxHeight ="{TemplateBinding MaxDropDownHeight}">
          <Border Background="{DynamicResource {x:Static SystemColors.WindowBrushKey}}" x:Name="DropDownBorder" BorderBrush="{DynamicResource {x:Static oui:OfficeBrushes.ComboBoxHoverBorderBrushKey}}" BorderThickness="1,1,1,1">
                    <DockPanel>
                        <Internals:PreviewThumb Style="{StaticResource bottomThumb}" PreviewMouseLeftButtonDown="UIElement_OnMouseDown"  DockPanel.Dock="Bottom" DragDelta="onThumbDrag" Tag="{Binding ElementName=PART_Popup}"/>
                        <ScrollViewer x:Name="ScrollViewer" ScrollViewer.HorizontalScrollBarVisibility="Hidden" CanContentScroll="True">
                            <ItemsPresenter x:Name="ItemsPresenter" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" KeyboardNavigation.DirectionalNavigation="Contained"/>
                        </ScrollViewer>
                    </DockPanel>
                </Border>
      </Popup>
    </Grid>
    <ControlTemplate.Triggers>
      <MultiTrigger>
        <MultiTrigger.Conditions>
          <Condition Property="IsSelectionBoxHighlighted" Value="True"/>
          <Condition Property="IsDropDownOpen" Value="False"/>
        </MultiTrigger.Conditions>
      <!--  <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.HighlightTextBrushKey}}"/> -->
      </MultiTrigger>
      <Trigger Property="HasItems" Value="False">
        <Setter Property="MinHeight" Value="95" TargetName="DropDownBorder"/>
      </Trigger>
      <Trigger Property="IsEnabled" Value="False">
        <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}"/>
        <Setter Property="Background" Value="{DynamicResource {x:Static SystemColors.ControlBrushKey}}" TargetName="Bd"/>
      </Trigger>
      <Trigger Property="ItemsControl.IsGrouping" Value="True">
        <Setter Property="ScrollViewer.CanContentScroll" Value="False"/>
      </Trigger>

    </ControlTemplate.Triggers>
  </ControlTemplate>
  <Style TargetType="{x:Type ComboBoxItem}" x:Key="{x:Static oui:Styles.RibbonComboBoxItemStyleKey}">
    <Setter Property="HorizontalContentAlignment" Value="{Binding HorizontalContentAlignment, RelativeSource={RelativeSource AncestorLevel=1, Mode=FindAncestor, AncestorType={x:Type ItemsControl}}}"/>
    <Setter Property="VerticalContentAlignment" Value="{Binding VerticalContentAlignment, RelativeSource={RelativeSource AncestorLevel=1, Mode=FindAncestor, AncestorType={x:Type ItemsControl}}}"/>
    <Setter Property="Padding" Value="3,0,30,0"/>
  <Setter Property="Background" Value="#00FFFFFF"/>
        <Setter Property="BorderThickness" Value="1"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type ComboBoxItem}">
                        <Border Background="{TemplateBinding Background}" x:Name="Bd" SnapsToDevicePixels="True"
                BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}"
                Padding="{TemplateBinding Padding}"
                      >
                            <ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                              VerticalAlignment="{TemplateBinding VerticalContentAlignment}" x:Name="ContentPresenter" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
                              Content="{TemplateBinding Content}" ContentTemplate="{TemplateBinding ContentTemplate}"/>
                        </Border>
                    <ControlTemplate.Triggers>

                        <Trigger Property="oui:HighlightElement.IsHighlighted" Value="True">
                            <Setter Property="Background" Value="{DynamicResource {x:Static oui:OfficeBrushes.ComboBoxArrowHoverBackgroundKey}}" TargetName="Bd"/>
                            <Setter Property="BorderBrush" Value="{DynamicResource {x:Static oui:OfficeBrushes.ComboBoxArrowHoverBorderBrushKey}}" TargetName="Bd"/>
                        </Trigger>
<!--                        <Trigger Property="IsHighlighted" Value="True">
                            <Setter Property="Background" Value="{DynamicResource {x:Static oui:OfficeBrushes.ComboBoxHoverArrowBackgroundKey}}" TargetName="Bd"/>
                            <Setter Property="BorderBrush" Value="{DynamicResource {x:Static oui:OfficeBrushes.ComboBoxHoverArrowBorderBrushKey}}" TargetName="Bd"/>
                        </Trigger>
    -->
                        <Trigger Property="IsEnabled" Value="False">
                            <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}"/>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
        <Style.Triggers>
            <Trigger Property="IsHighlighted" Value="True">
                <Setter Property="oui:HighlightElement.IsHighlighted" Value="True"/>
            </Trigger>
        </Style.Triggers>

    </Style>

  <Style x:Key="{x:Static oui:Styles.RibbonComboBoxStyleKey}" TargetType="{x:Type ComboBox}">
    <Setter Property="Template" Value="{StaticResource ComboBoxControlTemplate1}"/>
    <Setter Property="BorderBrush" Value="{DynamicResource {x:Static oui:OfficeBrushes.RibbonComboBoxBorderBrushKey}}"/>
    <Setter Property="BorderThickness" Value="1"/>
        <Setter Property="Background" Value="{DynamicResource {x:Static oui:OfficeBrushes.RibbonComboBoxBackgroundKey}}"/>
    <Setter Property="Padding" Value="0"/>
    <Setter Property="Height" Value="22"/>
    <Setter Property="VerticalContentAlignment" Value="Center"/>

    <Setter Property="ItemContainerStyle" Value="{StaticResource {x:Static oui:Styles.RibbonComboBoxItemStyleKey}}">
    </Setter>
    <Style.Triggers>
                <Trigger Property="IsEditable" Value="True">
        <Setter Property="IsTabStop" Value="False"/>
        <Setter Property="Padding" Value="0,1,0,1"/>
        <Setter Property="Template">
          <Setter.Value>
            <ControlTemplate TargetType="{x:Type ComboBox}">
              <Grid x:Name="Grid" SnapsToDevicePixels="True">
                <Border Background="{TemplateBinding Background}" x:Name="Bd" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Padding="1,1,1,1">
                    <Grid Grid.IsSharedSizeScope="True" x:Name="Grid1">
                    <Grid.ColumnDefinitions>
                      <ColumnDefinition Width="1"/>
                      <ColumnDefinition Width="*"/>
                      <ColumnDefinition Width="Auto" SharedSizeGroup="ComboBoxButton"/>
                    </Grid.ColumnDefinitions>
                    <TextBox Margin="{TemplateBinding Padding}" Grid.Column="1" x:Name="PART_EditableTextBox2" 
                             HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}" 
                             Text="{TemplateBinding Text}" 
                      VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}" 
                      IsReadOnly="{Binding IsReadOnly, RelativeSource={RelativeSource Mode=TemplatedParent, AncestorType={x:Null}}}" >
                      <TextBox.Style>
                        <Style TargetType="{x:Type TextBox}">
                          <Setter Property="OverridesDefaultStyle" Value="True"/>
                          <Setter Property="AllowDrop" Value="True"/>
                          <Setter Property="MinWidth" Value="0"/>
                          <Setter Property="MinHeight" Value="0"/>
                          <Setter Property="FocusVisualStyle" Value="{x:Null}"/>
                          <Setter Property="Template">
                            <Setter.Value>
                              <ControlTemplate TargetType="{x:Type TextBox}">
                                <ScrollViewer Focusable="False" HorizontalScrollBarVisibility="Hidden" VerticalScrollBarVisibility="Hidden" Background="#00FFFFFF" x:Name="PART_ContentHost"/>
                              </ControlTemplate>
                            </Setter.Value>
                          </Setter>
                        </Style>
                      </TextBox.Style>
                    </TextBox>
                    <ToggleButton Grid.ColumnSpan="3" Background="{x:Null}" x:Name="ToggleButton" IsChecked="{Binding IsDropDownOpen, Mode=TwoWay, RelativeSource={RelativeSource Mode=TemplatedParent, AncestorType={x:Null}}}">
                      <ToggleButton.Style>
                        <Style TargetType="{x:Type ToggleButton}">
                          <Setter Property="MinWidth" Value="0"/>
                          <Setter Property="MinHeight" Value="0"/>
                          <Setter Property="Width" Value="Auto"/>
                          <Setter Property="Height" Value="Auto"/>
                          <Setter Property="Background" Value="#00FFFFFF"/>
                          <Setter Property="Focusable" Value="False"/>
                          <Setter Property="ClickMode" Value="Press"/>
                          <Setter Property="Template" Value="{StaticResource toggleBInCB}">
                          </Setter>
                        </Style>
                      </ToggleButton.Style>
                    </ToggleButton>
                  </Grid>
                </Border>
                <Popup IsOpen="{Binding IsDropDownOpen, RelativeSource={RelativeSource Mode=TemplatedParent, AncestorType={x:Null}}}" Focusable="False" Placement="Bottom" x:Name="PART_Popup" PopupAnimation="{DynamicResource {x:Static SystemParameters.ComboBoxPopupAnimationKey}}" AllowsTransparency="True"
                       MaxHeight="{TemplateBinding MaxDropDownHeight}">
                    <Border Background="{DynamicResource {x:Static SystemColors.WindowBrushKey}}" x:Name="DropDownBorder" BorderBrush="{DynamicResource {x:Static SystemColors.WindowFrameBrushKey}}" BorderThickness="1,1,1,1">
                      <ScrollViewer x:Name="ScrollViewer">
                        <ItemsPresenter x:Name="ItemsPresenter" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" KeyboardNavigation.DirectionalNavigation="Contained"/>
                      </ScrollViewer>
                    </Border>
                </Popup>
              </Grid>
              <ControlTemplate.Triggers>
                <Trigger Property="HasItems" Value="False">
                  <Setter Property="MinHeight" Value="95" TargetName="DropDownBorder"/>
                </Trigger>
                <Trigger Property="IsEnabled" Value="False">
                  <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}"/>
                  <Setter Property="Background" Value="{DynamicResource {x:Static SystemColors.ControlBrushKey}}" TargetName="Bd"/>
                </Trigger>
                <Trigger Property="IsGrouping" Value="True">
                  <Setter Property="ScrollViewer.CanContentScroll" Value="False"/>
                </Trigger>
                <!--<Trigger Property="Popup.HasDropShadow" SourceName="PART_Popup" Value="True">
                  <Setter Property="Margin" Value="0,0,5,5" TargetName="Shdw"/>
                  <Setter Property="Color" Value="#71000000" TargetName="Shdw"/>
                </Trigger> -->
              </ControlTemplate.Triggers>
            </ControlTemplate>
          </Setter.Value>
        </Setter>
      </Trigger>
    </Style.Triggers>

  </Style>
</ResourceDictionary>